#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


class Info {
public:
    int id;
    int total;

    Info() : id(0), total(0) {}
};

bool compare(Info i, Info j) {
    return i.total > j.total;
}

int main() {
    int n;
    cin >> n;
    int num = 0;
    vector<Info> vec{};
    for (int i = 0; i < n; i++) {
        Info info;
        int score[3];
        cin >> info.id >> score[0] >> score[1] >> score[2];
        info.total = score[0] + score[1] + score[2];
        if (score[0] >= 80 && score[1] >= 80 && score[2] >= 80) {
            vec.push_back(info);
            num++;
        }
    }
    sort(vec.begin(), vec.end(), compare);

    for (auto it = vec.cbegin(); it != vec.cend(); it++) {
        cout << it->id << " " << it->total << endl;
    }
    if (num == 0) {
        cout << "NULL";
    }
}